﻿Imports ATS.Data
Imports System.Collections.ObjectModel
Imports ATS.Business.Entities

Public Class IObserveUserTableComponent
    Inherits ObservableCollection(Of UserTable)

    Private Shared list As New IObserveUserTable

    Public Shared Function GetList() As IObserveUserTable
        Return list
    End Function

    Private Sub New()
        ' Make the constructor private, enforcing the 
        ' "factory" concept -- the only way to create
        ' an instance of this class is by calling
        ' the GetList method.
        AddItems()

    End Sub

    Private Sub AddItems()
        Dim dac As New AssetDataAccess()
        Try
            Dim user As UserTable
            For Each user In dac.GetAllUsers
                With user
                    Add(New UserTable(.Unique_Key _
                                                , .Username _
                                                , .Hashed _
                                                , .Salt _
                                                , .LastPasswordChangeDateTime _
                                                , .AccountLocked _
                                                , .LockedDateTime _
                                                , .NumberOfPasswordTry _
                                                , .LastLogin _
                                                , .ChangePassword))
                End With

            Next
        Catch ex As Exception
            Console.WriteLine(ex.Message)
            Throw ex
        End Try
    End Sub
End Class
